Distance between bitstrings

Here we will draw the histogram of the distance between two random bitstrings.


In [1]:
import sdm as sdmlib
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
distances = []
for i in xrange(5000):
    b1 = sdmlib.Bitstring.init_random(1000)
    b2 = sdmlib.Bitstring.init_random(1000)
    distances.append(b1.distance_to(b2))

In [3]:
plt.hist(distances, bins=1000)
plt.xlim(0, 1000)
plt.show()



In [ ]: